package com.raulraja.model.manager;

import com.raulraja.model.domain.impl.Person;
import com.raulraja.persistence.PersistenceAdapter;

import java.io.Serializable;

/**
 * Default impl for the Person Manager
 */
public class PersonManagerImpl implements PersonManager {

	/**
	 * the Person based persistence adapter
	 */
	private PersistenceAdapter<Person> personPersistenceAdapter;

	/**
	 * Sets the persistence adapter, usually injected by an IOC container
	 * @param personPersistenceAdapter the person based persistence adapter
	 */
	public void setPersonPersistenceAdapter(PersistenceAdapter<Person> personPersistenceAdapter) {
		this.personPersistenceAdapter = personPersistenceAdapter;
	}

	/**
	 * Finds a person
	 *
	 * @param id the persons unique identifier
	 * @return the found person
	 */
	public Person find(Serializable id) {
		return personPersistenceAdapter.findById(Person.class, id);
	}
}
